package com.yunxin.core.infra.persistence.repository.channel;

import com.yunxin.core.domain.model.channel.ChannelPromotionUnitPriceConfigVersion;
import com.yunxin.core.domain.model.channel.ChannelPromotionUnitPriceConfigVersionRepository;
import com.yunxin.core.infra.persistence.converter.ChannelConvertor;
import com.yunxin.core.infra.persistence.entity.channel.ChannelPromotionUnitPriceConfigVersionDO;
import com.yunxin.core.infra.persistence.mapper.channel.ChannelPromotionUnitPriceConfigVersionExtendMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

/**
 * @author zero°
 * @since 2023-07-12
 */
@Repository
@RequiredArgsConstructor
public class ChannelPromotionUnitPriceConfigVersionRepositoryImpl implements ChannelPromotionUnitPriceConfigVersionRepository {

    private final ChannelPromotionUnitPriceConfigVersionExtendMapper channelPromotionUnitPriceConfigVersionExtendMapper;

    private final ChannelConvertor channelConvertor;
    @Override
    public boolean saveChannelPromotionUnitPriceConfigVersion(ChannelPromotionUnitPriceConfigVersion channelPromotionUnitPriceConfigVersion) {
        ChannelPromotionUnitPriceConfigVersionDO channelPromotionUnitPriceConfigVersionDO = channelConvertor.formChannelPromotionUnitPriceConfigVersion(channelPromotionUnitPriceConfigVersion);
        int count = channelPromotionUnitPriceConfigVersionExtendMapper.insertSelective(channelPromotionUnitPriceConfigVersionDO);
        return count > 0;
    }


}
